|
1
|
|
|
var chai = require('chai'); |
|
2
|
|
|
var path = require('path'); |
|
3
|
|
|
|
|
4
|
|
|
var config = require('../src/cli').config |
|
5
|
|
|
config.set({root: path.join(__dirname,'fixtures')}) |
|
6
|
|
|
|
|
7
|
|
|
var Page = require('../src/cli').Page |
|
8
|
|
|
var Manager = require('../src/cli').Manager; |
|
9
|
|
|
var cmsData = require('../src/cli').cmsData; |
|
10
|
|
|
var fse = require('fs-extra'); |
|
11
|
|
|
|
|
12
|
|
|
describe('Cms', function() { |
|
13
|
|
|
before( function(done) { |
|
14
|
|
|
Manager.instance.init() |
|
15
|
|
|
.then(function () { |
|
16
|
|
|
Manager.instance._whereKeys = ['title', 'priority', 'abe_meta', 'articles'] |
|
17
|
|
|
Manager.instance.updateList() |
|
18
|
|
|
|
|
19
|
|
|
this.fixture = { |
|
20
|
|
|
templateArticleRequired: fse.readFileSync(path.join(__dirname, 'fixtures/templates/article-required.html'), 'utf8'), |
|
21
|
|
|
templateArticle: fse.readFileSync(path.join(__dirname, 'fixtures/templates/article.html'), 'utf8'), |
|
22
|
|
|
jsonArticle: fse.readJsonSync(path.join(__dirname, '/fixtures/files/article-4.json')) |
|
23
|
|
|
} |
|
24
|
|
|
done() |
|
25
|
|
|
|
|
26
|
|
|
}.bind(this)) |
|
27
|
|
|
}); |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* new Page() |
|
31
|
|
|
* |
|
32
|
|
|
*/ |
|
33
|
|
|
it('new Page()', function() { |
|
34
|
|
|
var page = new Page(this.fixture.jsonArticle.abe_meta.template, this.fixture.templateArticle, this.fixture.jsonArticle, true) |
|
35
|
|
|
chai.expect(page.html).to.not.be.undefined; |
|
|
|
|
|
|
36
|
|
|
}); |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* cmsData.utils.getPercentOfRequiredTagsFilled() |
|
40
|
|
|
* |
|
41
|
|
|
*/ |
|
42
|
|
|
it('cmsData.utils.getPercentOfRequiredTagsFilled()', function() { |
|
43
|
|
|
var percent = cmsData.utils.getPercentOfRequiredTagsFilled(this.fixture.templateArticleRequired, this.fixture.jsonArticle) |
|
44
|
|
|
chai.expect(percent).to.equal(100); |
|
45
|
|
|
}); |
|
46
|
|
|
}); |
|
47
|
|
|
|